/**
 * 
 */
package vanhoc.android.mediakool.custom.adapter;

import java.util.ArrayList;
import java.util.List;

import vanhoc.android.medialcool.item.data.SongItemData;
import vanhoc.android.medialcool.item.layout.SongItemView;

import android.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

/**
 * @author Administrator
 *
 */
public class SongListAdapter extends ArrayAdapter<SongItemData> {
	private Context mContext;
	
	private ArrayList<SongItemData> arrListSongData;
	
	//Bien luu id cua bai hat dang choi
	private int songPlayingID = 0;
	
	//trang thai play/pause
	private Boolean isPlaying = true;
	
	public SongListAdapter(Context context, int textViewResourceId, List<SongItemData> objects) {
		super(context, textViewResourceId, objects);
		this.mContext		=	context;
		arrListSongData		=	(ArrayList<SongItemData>) objects;
	}
	
	
	public void setSongPlayingID(int songID){
		this.songPlayingID	=	songID;
	}
	
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		SongItemView songItemView = new SongItemView(mContext);
		
		//set icon khac cho bait hat dang hat
		if (this.songPlayingID != 0 && arrListSongData.get(position).getID() == this.songPlayingID) {
			songItemView.ivSongIcon.setImageResource(vanhoc.android.mediakool.R.drawable.play_32_icon_green);
		}
		
		songItemView.txtSongName.setText(arrListSongData.get(position).getName());
		songItemView.txtSongArtist.setText(arrListSongData.get(position).getArtist());
		songItemView.txtSongDuration.setText(arrListSongData.get(position).getDuration());
		songItemView.setTag(arrListSongData.get(position).getID());
		
		return songItemView;
	}
}
